function [f1,f2,setime,manufacturetime,z] = ManufactureCost(chrome,m_no,DELIVERPlate,availableMachine,Vcut,LENGTHPlate,Setup,Setdown);
 T1=5
%T1=10; %����������
 % T2=-30; 
  delay_cost=zeros;
  advance_cost=zeros;
  punctual_cost=zeros;
 % chrome��Ⱦɫ�����
% m_no:���и�ӹ��İ������
% LENGTHPlate�������ĵ��и��
% DELIVERPlate����ĵĽ�����
% DELIVERDelayCost�����ڽ����ɱ�
% INVENTORYCost�����ɱ�
% COSTPlate����ĵĳɱ�
% STARTCost����������ɱ�
% W���и���ĵ�λ�и�ɱ�[Wcd Wcf]
% availableMachine��ÿ�������и������������[2 3]���������ͣ���һ������̨���ڶ�������̨
% Vcut���и��ٶ�
% f1������깤ʱ��
% f2���ܵ�����

    seqence = chrome(1,1:m_no);
    machineDis = chrome(1,m_no+1:end);
    z=zeros(1,m_no);
    [f1,setime,manufacturetime] = TimeCost(chrome,m_no,availableMachine,Vcut,LENGTHPlate,Setup,Setdown);%manufacturetime�����˰�ĵĿ�ʼ�ӹ�ʱ��ͽ����ӹ�ʱ��
   % f4=sum(setime(3,:))
    %  for i=1:m_no
      %  if (DELIVERPlate(1,chrome(i))-setime(4,i))<0
       %     z(1,i)=setime(4,i)-DELIVERPlate(1,chrome(i));
       % else
      %  end
   % end
    % f2=sum(z);
  %   wgcost= sum(setime(4,:)*1.5)     %(�깤ʱ��ɱ�)
   
%����ǰ/�ӳٳɱ�
  for i=1:m_no;
           m =DELIVERPlate(1,chrome(i));
           v =m{1};
           k=size(v,1);
            z=zeros(1,k)
           for g= 1:k
         if setime(3,i)-v(g,1)>10;
           z(1,g)=setime(3,i)-v(g,1);
           delayovertime(1,g)= z(1,g)-10;
          % w(1,i)=z(1,i)/DELIVERPlate(1,chrome(i));%delaytime
     delay(1,g)=  delayovertime(1,g)*1.5    %delay(1,g)=  delayovertime(1,g)*0.3;  %*w(1,i);
          delay_cost=sum(delay,2);
     %   elseif setime(4,i)-v(g,1)<T2;
      %     f(1,g)= setime(4,i)-v(g,1) ; %advancetime
          % g(1,i)=abs(z(1,i))/DELIVERPlate(1,chrome(i));
       %    advance(1,g)=abs(f(1,g));  % *g(1,i);
        %   advanceovertime(1,g)=(advance(1,g)-30)*0.5;
         %   advance_cost=sum(advanceovertime,2);
       elseif  setime(3,i)-v(g,1)<=10;
         q(1,g)=v(g,1)-setime(3,i);
           j(1,g)=0;
            punctual(1,g)=q(1,g)*j(1,g);
           punctual_cost=sum(punctual,2); 
         end
           end
           
     f3(i,1)=delay_cost
  end
   %f2=delay_cost %advance_cost
 %  zcost=wgcost+ f2
f2=sum(f3,1)
end  
  
  
  
  
  
  
%     plateCost = COSTPlate;
%     startCost = STARTCost;    
%     pre_cost = 0; 
%     for i = 1:m_no
%         pre_cost = pre_cost + plateCost(i) + startCost(i);
%     end
%     
%     deliverTime = DELIVERPlate;
%     deliverDelayCost = DELIVERDelayCost;
%     inventoryCost = INVENTORYCost;
%     
%     delay_cost = 0;
%     inventory_cost = 0;6
%     delay_num = 0;
%     for j = 1:m_no
%         Index = find(j == seqence);
%         finishCutTime = manufacturetime(2,Index);
%         
%         if (finishCutTime > deliverTime(j))
%             delay_cost = delay_cost + (finishCutTime - deliverTime(j))*deliverDelayCost(j);
%             delay_num = delay_num + 1;
%         else
%             inventory_cost = inventory_cost + (deliverTime(j) - finishCutTime)*inventoryCost(j);
%         end
%     end
%        
%     cut_cost = 0;    
%     cutLength = LENGTHPlate;
%     for i = 1:m_no
%         machineType = machineDis(i);
%         cut_cost = cut_cost + W(machineType)*cutLength(seqence(i));
%     end
%     
%     f2 = pre_cost + delay_cost + inventory_cost + cut_cost;
